package instruments;

import collision.MainWindow;
import data.NavmeshRegion;

/**
 * @author sad
 */
public class NewPolygonInstrument extends AbstractPolygonInstrument {

    private NavmeshRegion area = new NavmeshRegion();
    private boolean isAdded = false;

    @Override
    public void mouseDown(int x, int y, int modifiers) {
        if (isLeftDown(modifiers)) {
            if (!isAdded) {
                MainWindow.getInstance().getExtAreas().add(area);
                isAdded = true;
            }

            area.addPolygonPoint(x, y);
            System.out.println("PolyPoint X=" + x + "  Y=" + y);
            area.updateBoundaries();
            redraw();
        }
    }

    @Override
    public void mouseMove(int x, int y, int oldX, int oldY) {
        super.mouseMove(x, y, oldX, oldY);
        MainWindow.getInstance().setTitle("X=" + x + "  Y=" + y);
    }
}
